
import pygame
from hexconfig import *


fileWutil = open("../ai_data/new0point2Nodes.pkl",'rb')
fileWOutil = open("../ai_data/hasNoUtil.pkl",'rb')

print "Loading file with utility"
nodesWutil = pickle.load(fileWutil)
print "Loading file w/o utility"
nodesWOutil = pickle.load(fileWOutil)

print "adding nodes w/o utility to dataset"

ds = DataSet()
ds.nodes = nodesWOutil

print "adding nodes with utility"
total = 0
for key in nodesWutil.keys():
    if nodesWutil[key].util()!= 0.0:
        ds.addNode(key)
        ds.nodes[key].u = nodesWutil[key].u
        ds.nodes[key].w = nodesWutil[key].w
        total+= 1

print "Nodes with added utility:", total
print "UTIL PROPOGATION PRINTOUTS:"
numWithUtil = 0
keys = ds.nodes.keys()
for k in keys:
    if not ds.nodes[k].util()==0.0:
        numWithUtil+=1
        #print ds.nodes[k].util(), ds.nodes[k].stateString, ds.nodes[k].w
print "  ", numWithUtil, "/", len(keys), "nodes have utility"

print "Saving data"

p = pickle.Pickler(open("../ai_data/Combined0point2Nodes"+".pkl",'wb'))
p.fast = True
p.dump(ds.nodes)
print "All done!"

